package com.theme.common.third.apple;

import org.apache.commons.httpclient.HttpStatus;

import java.util.HashMap;
import java.util.Map;


/**
 * @name: AppleRpcResult <tb>
 * @title: 请输入类描述  <tb>
 * @author: cuixinfu@51play.com <tb>
 * @date: 2021/10/25 10:41:43 <tb>
 */
public class AppleRpcResult extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public AppleRpcResult() {
        put("code", 0);
        put("msg", "success");
    }

    public static AppleRpcResult error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static AppleRpcResult error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static AppleRpcResult error(int code, String msg) {
        AppleRpcResult r = new AppleRpcResult();
        r.put("code", code);
        r.put("msg", msg);

        return r;
    }

    public static AppleRpcResult ok(String msg) {
        AppleRpcResult r = new AppleRpcResult();
        r.put("msg", msg);

        return r;
    }

    public static AppleRpcResult ok(Map<String, Object> map) {
        AppleRpcResult r = new AppleRpcResult();
        r.putAll(map);

        return r;
    }

    public static AppleRpcResult ok() {
        return new AppleRpcResult();
    }

    public AppleRpcResult put(String key, Object value) {
        super.put(key, value);

        return this;
    }
}
